package com.ks.fission.controller;


import com.ks.core.base._ControllerBase;
import com.ks.core.core.Result;
import com.ks.core.dto.OperateBase;
import com.ks.core.dto.SearchCriteriaBase;
import com.ks.fission.entity.BFissionTask;
import com.ks.fission.service.IBFissionTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.Map;

/**
 * <p>
 * 裂变-租户添加的分享裂变任务 前端控制器
 * </p>
 *
 * @author kingdee123
 * @since 2020-12-21
 */
@RestController
@RequestMapping("/bFissionTask")
@Api(value = "分享裂变任务模块", description = "分享裂变任务模块")
public class BFissionTaskController extends _ControllerBase {

    @Resource
    private IBFissionTaskService ibFissionTaskService;

    @PostMapping("/insertBFissionTask")
    @ApiOperation(value = "管理分享任务添加", notes = "BFissionTask 任务添加需要的数据")
    public Object insertBFissionTask(@RequestBody BFissionTask bFissionTask) {
        bFissionTask.setOrgID(getContext().getOrgId().intValue());
        bFissionTask.setOrgSubID(getContext().getOrgSubId().intValue());
        bFissionTask.setTenantID(getContext().getTenantId().intValue());
        bFissionTask.setCreateUserID(getContext().getUserId().intValue());
        bFissionTask.setUpdateUserID(getContext().getUserId().intValue());
        bFissionTask.setUpdateTime(new Date());
        int i = ibFissionTaskService.insertBFissionTask(getContext(), bFissionTask);
        return Result.success(i);
    }

    @PostMapping("/deleteBFissionTask")
    @ApiOperation(value = "管理分享任务删除", notes = "BFissionTask 任务删除的数据")
    public Object deleteBFissionTask(@RequestBody OperateBase operateBase) {
        int i = ibFissionTaskService.deleteBFissionTask(getContext(), operateBase);
        return Result.success(i);
    }

    @PostMapping("/updateBFissionTask")
    @ApiOperation(value = "管理分享任务修改", notes = "BFissionTask 任务修改的数据")
    public Object updateBFissionTask(@RequestBody BFissionTask bFissionTask) {
        int i = ibFissionTaskService.updateBFissionTask(getContext(), bFissionTask);
        return Result.success(i);
    }

    @PostMapping("/selectBFissionTaskList")
    @ApiOperation(value = "管理分享任务列表查找", notes = "BFissionTask 任务查找的条件；分页条件,查询条件字段taskName,state")
    public Object selectBFissionTaskList(@RequestBody SearchCriteriaBase searchCriteriaBase) {
        Map<String, Object> resultMap = ibFissionTaskService.selectBFissionTaskList(getContext(), searchCriteriaBase);
        return Result.success(resultMap);
    }

    @PostMapping("/selectGetBFissionTaskList")
    @ApiOperation(value = "管理任务领取清单查询", notes = "tenantID 租户代码 createUserID 创建人 createTime 创建时间；分页条件")
    public Object selectGetBFissionTaskList(@RequestBody SearchCriteriaBase searchCriteriaBase) {
        Map<String, Object> resultMap = ibFissionTaskService.selectGetBFissionTaskList(getContext(), searchCriteriaBase);
        return Result.success(resultMap);
    }

    @PostMapping("/issueBFissionTask")
    @ApiOperation(value = "分享任务发布", notes = "标准操作对象ids")
    public Object issueBFissionTask(@RequestBody OperateBase operateBase) {
        int i = ibFissionTaskService.issueBFissionTask(getContext(), operateBase);
        return Result.success(i);
    }

    @PostMapping("/isStateFissionTask")
    @ApiOperation(value = "分享任务撤回", notes = "标准操作对象ids")
    public Object isStateFissionTask(@RequestBody OperateBase operateBase) {
        int i = ibFissionTaskService.isStateFissionTask(getContext(), operateBase);
        return Result.success(i);
    }

    @PostMapping("/getBFissionTaskAdminCount")
    @ApiOperation(value = "分享营销数", notes = "分享营销数")
    public Object getBFissionTaskAdminCount() {
        Map<String, Object> bFissionTaskAdminCount = ibFissionTaskService.getBFissionTaskAdminCount(getContext());
        return Result.success(bFissionTaskAdminCount);
    }

    @PostMapping("/getBFissionTaskUserCount")
    @ApiOperation(value = "租户裂变分享", notes = "租户裂变分享")
    public Object getBFissionTaskUserCount() {
        Map<String, Object> bFissionTaskAdminCount = ibFissionTaskService.getBFissionTaskUserCount(getContext());
        return Result.success(bFissionTaskAdminCount);
    }
}

